@extends('backend::layout')
@section('title',trans($page_title))
@push('styles')
    <link rel="stylesheet" type="text/css" href="{{asset(config('view.backend.theme.theme2').'/css/wizard.css')}}">
    <link href="{{asset(config('view.plugin').'/layui/layui_ext/cascader/cascader.css')}}" rel="stylesheet">
@endpush
@section('content')
    @component('backend::component.form.form')
        @slot('page_title') {{$page_title}} @endslot
        @slot('formId') add-goods @endslot
        @slot('attr') class = wizard @endslot
        @slot('action') {{route('b_ShopGoods_update',['id'=>$goods->goods_id])}} @endslot
        @component('backend::component.form.form-steps',['steps'=>[
                ['title'=>'商品信息','href'=>'goods-base','icon'=>'hcl-goods','is_show'=>true],
                ['title'=>'商品属性','href'=>'goods-attr','icon'=>'hcl-cs','is_show'=>true],
                ['title'=>'商品详情','href'=>'goods-detail','icon'=>'hcl-wangye','is_show'=>true],
            ]])
        @endcomponent
        @include('backend::shop.goods.edit_section.goods_base',['id'=>'goods-base'])
        @include('backend::shop.goods.edit_section.goods_attr',['id'=>'goods-attr'])
        @include('backend::shop.goods.edit_section.goods_detail',['id'=>'goods-detail'])

        @slot('buttons')
            @slot('class') justify-content-end @endslot
            @component('backend::component.form.button')
                @slot('title') 上一步 @endslot
                @slot('elem') a @endslot
                @slot('href') #previous @endslot
                @slot('btn') btn @endslot
                @slot('size') sm @endslot
                @slot('class') d-none step-btn mr-2 @endslot
                @slot('color') danger @endslot
            @endcomponent

            @component('backend::component.form.button')
                @slot('title') 下一步 @endslot
                @slot('elem') a @endslot
                @slot('btn') btn @endslot
                @slot('class') step-btn mr-2 @endslot
                @slot('href') #next @endslot
                @slot('size') sm @endslot
                @slot('color') danger @endslot
            @endcomponent

            @component('backend::component.form.button')
                @slot('title') 提交 @endslot
                @slot('size') sm @endslot
                @slot('params') {"formId":"#add-goods"} @endslot
                @slot('class') btn-min-width ajax-form d-none @endslot
            @endcomponent

        @endslot
    @endcomponent
@endsection
@include('backend::component.upload.upload_js')
@push('scripts')
    <script src="{{asset(config('view.backend.theme.theme2').'/js/shop.js')}}"></script>
    <script src="{{asset(config('view.backend.theme.theme2').'/js/modules/wizard-steps.js')}}"></script>
    <script>
        layui.use(['jquery','layer','cascader'], function(){
            var $ = layui.jquery;
            var cascader = layui.cascader;
            selectParentAction();
            goodsTypeInit($('#goods_type'));


            function selectParentAction() {
                var data = $('#action_parent').data('parents');
                var defaultVal = $('#action_parent').data('default').toString();
                if(defaultVal&&defaultVal.indexOf(",") != -1){
                    var defaultValArr = defaultVal.split(",").filter(function (value) { return value; });
                }else{
                    var defaultValArr = [defaultVal?defaultVal:0];
                }
                cascader({
                    elem: "#action_parent",
                    data: data,
                    triggerType: "change",
                    // showLastLevels:true,
                    value: defaultValArr,
                    changeOnSelect:true,
                    success:function (valData) {
                        $('#parent-value').val(valData);
                    }
                });
            }
        });
    </script>
@endpush
